
'use strict';

/**
	Part of Zombie Navigator
	Copyright © 2015  Zombie Navigator Developers
	
	@file
	@module
	@license AGPL-3.0+
*/


/* Used modules */
const _modSandbox = require('../platform/sandbox');
const _modModuleLoader = require('../platform/module-loader');
const _modNotification = require('../platform/notification');


/* Internal properties */

/**
	Whitelist of allowed pseudo-module IDs
	@private
*/
const _moduleIDs = [
	'zombie/zombie'
	, 'zombie/webbrowser'
	, 'zombie/async'
];


/**
	Run a Zombie script in a sandboxed environment
	@public
*/
const runScript = function (scriptURI) {
	const modSandbox = _modSandbox;
	const modModuleLoader = _modModuleLoader;
	const modNotification = _modNotification;
	
	/* Show GUI notification */
	modNotification.showNotification('Running script: ' + scriptURI);
	
	/*
		Pseudo-modules available to Zombie scripts
	*/
	const modules = modModuleLoader.loadModules(_moduleIDs);
	
	return modSandbox.runInSandbox(scriptURI + '', modules);
};


/*
	Exports
*/
exports.runScript = runScript;


// vim: ts=4 noet ai

